package com.bawei.mvvm.utills

import android.content.Context
import android.content.SharedPreferences
import com.bawei.mvvm.App

object SPUtils {
    private var sharedPreferences:SharedPreferences
    private var editor:SharedPreferences.Editor
    //初始化
    init {
        sharedPreferences = App.instance.getSharedPreferences("mvvm",Context.MODE_PRIVATE)
        editor = sharedPreferences.edit()
    }


    fun putString(key:String,value:String){
        editor.putString(key,value)
            .commit()
    }

    fun putInt(key:String,value:Int){
        editor.putInt(key,value)
            .commit()
    }

    fun clear(){
        editor.clear()
            .commit()
    }


    fun  getString(key:String):String?{
        return sharedPreferences.getString(key,"")
    }

    fun  getInt(key:String):Int?{
        return sharedPreferences.getInt(key,0)
    }




}